<?php

namespace app\model;

use think\Model;

class BannerModel  extends Model
{
    protected $name = 'banner';

    protected $pk = 'id'; // 明确声明主键字段
    // 自动时间戳
    protected $autoWriteTimestamp = 'datetime';
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    // 生成18位唯一ID（雪花算法简化版）
    public static function generateBannerId(): int
    {
        $timestamp = (int)(microtime(true) * 1000);
        $random = mt_rand(1000, 9999);
        return (int)($timestamp . $random);
    }
}